package com.ysu.shop.service.impl;

import com.ysu.shop.exception.MyException;
import com.ysu.shop.mapper.OrderdetailMapper;
import com.ysu.shop.pojo.Orders;
import com.ysu.shop.mapper.OrdersMapper;
import com.ysu.shop.service.IOrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 霍京
 * @since 2021-3-03
 */
@Service
@Transactional(noRollbackFor={MyException.class},rollbackFor = Exception.class)
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements IOrdersService {

    @Resource
    private OrdersMapper ordersMapper;

    @Resource
    private OrderdetailMapper orderdetailMapper;

    @Override
    public int payment(String orderNo,int shippingId) {
        ordersMapper.payment(orderNo,shippingId);
        return orderdetailMapper.payment(orderNo);
    }

    @Override
    public int cancel(String orderNo) {
        ordersMapper.cancel(orderNo);
        return orderdetailMapper.cancel(orderNo);
    }
}
